<?php

trait Trait_Api_Product
{
    /**
     * 获取产品详情
     * @param $typeid
     * @param $productid
     * @return array|mixed
     */
    public function get_product_info($typeid, $productid)
    {
        $info = Model_Model::get_module_info($typeid);
        if (empty($info['maintable'])) {
            return array();
        }
        if ($typeid == 5) {
            $w = ' and ishidden=0';
        }else{
            $w = ' and status=3';
        }
        $row = DB::select()
            ->from($info['maintable'])
            ->where('id', '=', $productid)
            ->where($w)
            ->execute()
            ->current();
        if (empty($row)) {
            return array();
        }
        $out = [];
        $out['product_id']  = $row['id'];
        $out['typeid']      = $typeid;
        $out['title']       = $row['title'];
        $out['typename']    = $info['modulename'];
        $out['litpic']      = $this->img_url($row['litpic']);
        $out['attrlist']    = Model_Api_V2_Product::get_product_attr($row['attrid'], $info['maintable']);
        if (isset($row['sellpoint']) && $row['sellpoint']) {
            $out['sellpoint']  = $row['sellpoint'];
        }
        return $out;
    }


}